package com.zfei.gfb.bean;

import com.zfei.gfb.util.Gsons;

public class Const {

    public static final String SESSION_COMPANY = "SESSION_COMPANY";
    public static final String SESSION_VILLAGER = "SESSION_VILLAGER";

    public static final String appId = "wx0f7cdbdfe42c9acf";
    public static final String appSecret = "1392f4468f0d41ad0037c79c9b3d04de";

    public static final String PREX_SMSCODE_FREQUENCY_CHECK = "SMS_CODE_FREQUENCY_CHECK_";
    public static final String PREX_SMSCODE_STORE = "SMS_CODE_STORE_";
    /**
     * 微信开放平台二维码连接
     */
    public final static String OPEN_QRCODE_URL = "https://open.weixin.qq.com/connect/qrconnect?appid=%s&redirect_uri=%s&response_type=code&scope=snsapi_login&state=%s#wechat_redirect";

    /**
     * 开放平台回调url
     * 注意：test16web.tunnel.qydev.com 域名地址要和在微信端 回调域名配置 地址一直，否则会报回调地址参数错误
     */
    public final static String OPEN_REDIRECT_URL = "http://newsweb.cnepaper.net/web/user/wxback";


    public static final int STATUS_OFF = 0;
    public static final int STATUS_ON = 1;
    public static final int STATUS_REFUSE = 2;

    public static final int USER_TYPE_PLATFORM = 1;
    public static final int USER_TYPE_MER = 2;


    //类型 0:游客 1:村民 2:企业
    public static final int GUEST = 0;
    public static final int VILLAGER = 1;
    public static final int COMPANY = 2;
    public static final int TOWN_MANAGER = 3;
    public static final int VILLAGE_MANAGER = 4;


    //---------gfb_user---------
    /**
     * gfb_user 镇类型
     */
    public static final int GFB_TOWN_MANAGER = 1;
    /**
     * gfb_user 村类型
     */
    public static final int GFB_VILLAGE_MANAGER = 2;

    //---------企业---------
    /**
     * 企业状态 未认证
     */
    public static final int COMPANY_UNAUTHORIZED = 0;
    /**
     * 企业状态 认证中
     */
    public static final int COMPANY_AUTHENTICATING = 1;
    /**
     * 企业状态 已认证
     */
    public static final int COMPANY_AUTH_SUCCESS = 2;
    /**
     * 企业状态 认证失败
     */
    public static final int COMPANY_AUTH_FAIL = 3;

    //--------房屋租赁---------
    /**
     * 短租
     */
    public static final int SHORT_RENTALS = 1;
    /**
     * 长租
     */
    public static final int LONG_RENTALS = 2;
    /**
     * 朝北
     */
    public static final int NORTH = 0;
    /**
     * 朝南
     */
    public static final int SOUTH = 1;
    /**
     * 朝东
     */
    public static final int EAST = 3;
    /**
     * 朝西
     */
    public static final int WEST = 2;
    /**
     * 房源审核状态 认证中
     */
    public static final int HOUSE_STATUS_ING = 0;
    /**
     * 房源审核状态 已认证
     */
    public static final int HOUSE_STATUS_ON = 1;
    /**
     * 房源审核状态 未通过
     */
    public static final int HOUSE_STATUS_OFF = 2;


    //--------物品---------
    /**
     * 物品售卖 线上
     */
    public static final int SALE_TYPE_ON = 1;
    /**
     * 物品售卖 线下
     */
    public static final int SALE_TYPE_OFF = 2;

    /**
     * 物品状态 下架
     */
    public static final int GOOD_OFF = 0;
    /**
     * 物品状态 上架
     */
    public static final int GOOD_ON = 1;
    /**
     * 物品状态 交易中
     */
    public static final int GOOD_DEAL = 2;
    /**
     * 物品状态 已兑换
     */
    public static final int GOOD_COMPLETED = 3;

    //--------求职---------
    /**
     * 企业发布
     */
    public static final int JOB_COM = 2;
    /**
     * 政府发布
     */
    public static final int JOB_GOV = 3;

    //--------土地---------
    /**
     * 土地
     */
    public static final int LAND = 1;
    /**
     * 池塘
     */
    public static final int POOL = 2;
    /**
     * 山林
     */
    public static final int FOREST = 3;


    //--------特殊数字---------
    /**
     * 内容长度
     */
    public static final int CONTENT_LENGTH = 220;
    /**
     * 名字长度
     */
    public static final int NAME_LENGTH = 20;
    /**
     * 图片大小
     */
    public static final int IMAGE_SIZE = 5;
    /**
     * 房屋面积
     */
    public static final int HOUSE_AREA = 300;

    public static boolean legalFace(Integer face) {
        if (face == null) {
            return true;
        }
        return face == NORTH || face == SOUTH || face == WEST || face == EAST;
    }

    public static void legalTwoStatus(Integer status) {
        if (status == null) {
            throw new StatusException(Status.INVALID_ARGUMENT);
        }
        if (status != STATUS_ON && status != STATUS_OFF) {
            throw new StatusException(Status.INVALID_ARGUMENT);
        }
    }

    public static void checkLandTypeWithNull(Integer type) {
        if (type == null) {
            return;
        }
        if (type != LAND && type != POOL && type != FOREST) {
            throw new StatusException(Status.INVALID_ARGUMENT);
        }
    }

    public static void legalGoodsSetStatus(Integer status) {
        if (status == null) {
            throw new StatusException(Status.INVALID_ARGUMENT);
        }
        if (status != GOOD_OFF && status != GOOD_ON && status != GOOD_DEAL && status != GOOD_COMPLETED) {
            throw new StatusException(Status.INVALID_ARGUMENT);
        }
    }

    public static boolean legalStatus(Integer status) {
        if (status == null) {
            return true;
        }
        return status == STATUS_ON || status == STATUS_OFF;
    }

    public static boolean isGuest(Integer userType) {

        return userType == null;
    }

    public static boolean isVillager(Integer userType) {
        if (userType == null) {
            return false;
        }
        return userType == VILLAGER;
    }

    public static boolean isCompany(Integer userType) {
        if (userType == null) {
            return false;
        }
        return userType == COMPANY;
    }


    public enum DaiCunTwon {
        dagaishi("大石盖村"),
        fosan("佛山村"),
        nansan("南三村"),
        shencun("沈村"),
        daicun("戴村"),
        zhangjianong("张家弄村"),
        badu("八都村"),
        hetanghu("河杨湖村"),
        yongfu("永富村"),
        fengqiao("枫桥村"),
        bansan("半山村"),
        jiansanxia("尖山下村"),
        dongfeng("东风村"),
        qingsan("青山村"),
        magu("马谷村"),
        shangdong("上董村"),
        luojiashe("骆家舍村"),
        gujiaxi("顾家溪村"),
        santoucun("三头村"),
        yujiasanxia("郁家山下村"),
        shimatou("石马头村"),
        shequ("社区"),
        fangxi("方溪村");


        private String name;

        DaiCunTwon(String name) {
            this.name = name;
        }

        public String getName() {
            return name;
        }

    }
}
